﻿#define _CRT_SECURE_NO_WARNINGS//offsetof宏
#include<stdio.h>
#include<stdlib.h>
//struct ss
//{
//	int a;
//	char m;
//	long long as;
//};
//int main()
//{
//	printf("%d\n", offsetof(struct ss, as));
//	return 0;
//}
#define OFFSETOF(s_type, m_name)   (int)&(((s_type*)0)->m_name)
struct S
{
	char a;//0
	int b;//4
	char c;//8
};
int main()
{
	printf("%d\n", OFFSETOF(struct S, a));
	printf("%d\n", OFFSETOF(struct S, b));
	printf("%d\n", OFFSETOF(struct S, c));

	//printf("%d\n", offsetof(struct S, a));
	//printf("%d\n", offsetof(struct S, b));
	//printf("%d\n", offsetof(struct S, c));

	return 0;
}
